// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

const int N = 4e4 + 50;

int t, n, m;
int a[N], b[N], k;

LL sc[N], sd[N];

vector<int> c, d;

vector<int> doit(int a[], int n) {
    vector<int> res;
    for (int i = 0, j; i < n; i=j+1) {
        
        j = i;
        if (a[i] == 0) continue;
        while (j+1<n && a[j+1] == a[i])
            ++j;
        res.push_back(j - i + 1);
    }
    return res;
}

LL cnt(int k, vector<int> &a, LL sa[]) {
    
    int num = a.end() - lower_bound(a.begin(), a.end(), k);
    if (num == 0)
        return 0;
    int n = a.size();
    LL sum = sa[n - num];
    sum -= 1LL * num * (k - 1);
    // dbg(a.size(), k, sum, num);
    return sum;
}

vector<pair<int, int>> rec;
int main(int argc, char const *argv[]) {
    // code
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i * i <= k; ++i) {
        if (k % i == 0) {
            rec.push_back(make_pair(i, k / i));
            if (i * i != k)
                rec.push_back(make_pair(k / i, i));
        }
    }

    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < m; ++i)
        scanf("%d", &b[i]);
    
    c = doit(a, n);
    d = doit(b, m);
    sort(c.begin(), c.end());
    sort(d.begin(), d.end());
    // dbg(c.size(), d.size());
    // return 0;
    sc[c.size()] = 0;
    sd[d.size()] = 0;
    // return 0;
    for (int i = c.size() - 1; i >= 0; --i) {
        // dbg(i);
        sc[i] = sc[i + 1] + c[i];
    }
    for (int i = d.size() - 1; i >= 0; --i)
        sd[i] = sd[i + 1] + d[i];
    LL ans = 0;
    // return 0;
    for (const auto &p : rec) {
        ans += cnt(p.first, c, sc) * cnt(p.second, d, sd);
    }
    cout << ans << endl;
    return 0;
}
